package com.yantong.service.impl;

import com.yantong.utils.PageUtils;
import com.yantong.pojo.StoreEvents;
import com.yantong.mapper.StoreEventsMapper;
import com.yantong.service.StoreEventsService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @author kanghaixin
 * @date 2018/9/25.11:22
 */
@Service
public class StoreEventsServiceImpl implements StoreEventsService {
    @Autowired
    private StoreEventsMapper storeEventsMapper;

    private static final Logger logger = LoggerFactory.getLogger(StoreEventsServiceImpl.class);

    @Override
    public PageUtils<StoreEvents> list(Map params) {
        PageUtils<StoreEvents> pageUtils = new PageUtils<>();

        int total = storeEventsMapper.queryTotal(params);
        if (total >0) {
            pageUtils.setTotal(total);
            pageUtils.setRows(storeEventsMapper.queryList(params));
        }
        return pageUtils;
    }

    @Override
    public int save(StoreEvents storeEvents) {
        return storeEventsMapper.insertSelective(storeEvents);
    }

    @Override
    public StoreEvents getByKey(Long id) {
        return storeEventsMapper.selectByPrimaryKey(id);
    }

    @Override
    public int update(StoreEvents storeEvents) {
        return storeEventsMapper.updateByPrimaryKeySelective(storeEvents);
    }

    @Override
    public List<StoreEvents> queryList(Map params) {
        return storeEventsMapper.queryList(params);
    }

    @Override
    public void delete(Long id) {
        storeEventsMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int queryTotal(Map params) {
        return storeEventsMapper.queryTotal(params);
    }

    @Override
    public StoreEvents getMaxEvents(Map map) {
        return storeEventsMapper.getMaxEvents(map);
    }
}
